<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="css/amazeui.min.css" />
    <link rel="stylesheet" href="css/index_2.css" />
    <link rel="stylesheet" type="text/css" href="css/pageCode.css">
    <title>我的激活码</title>
</head>

<body>
    <!--头部-->
    <header class="am-u">
        <div class="am-u-sm-12 head_nav" style="margin:0;">
            <div class="am-u-sm-2 am-vertical-align">
                <a href="Activationcode.html">
                    <img src="img/return@2x.png" class="am-vertical-align-middle" alt="" />
                </a>
            </div>
            <div class="am-u-sm-8 head_text">
                我的激活码
            </div>
            <div class="am-u-sm-2">

            </div>
        </div>
    </header>
    <!--修改密码输入框-->
    <div style="clear:both"></div>
    <div class="am-u" id="jh_list">
        <!--			<div class="am-u-sm-12" style="padding: 10px 20px 15px 20px;background: #fff;margin-bottom: 5px;">
                            <div>
                                <div class="am-u-sm-6" style="font-size: 16px;padding:0;">
					9455215
				</div>
				<div class="am-u-sm-6" style="text-align: right;">
					<img src="img/Used@2x.png" width="45" alt="" />
				</div>
                            </div>
                            <div class="am-u-sm-12" style="padding:0;font-size:14px;margin-top:3px;">有效期至：<span>2017-25-21 25:21:12</span></div>
                            <div style="clear: both;"></div>
			</div>
                        <div class="am-u-sm-12" style="padding: 10px 20px 15px 20px;background: #fff;margin-bottom: 5px;">
                            <div>
                                <div class="am-u-sm-6" style="font-size: 16px;padding:0;">
					9455215
				</div>
				<div class="am-u-sm-6" style="text-align: right;">
					<img src="img/unUse@2x.png" width="45" alt="" />
				</div>
                            </div>
                            <div style="clear: both;"></div>
			</div>-->
    </div>
    <div class="tcdPageCode" style="color: red;text-align: center;"></div>
    <script src="js/jquery-1.11.3.js"></script>
    <script src="js/jquery.page.js"></script>
    <script src="js/loading.js"></script>
    <script>
        var token1 = sessionStorage['token'];
        var method1 = "InvitationCode|code_list";
        //      第几页
        var p1 = 1;
        //      每页几条数据
        var pagesize1 = 10;
        $.ajax({
            type: 'POST',
            url: "http://www.rice.com/app/api/h5_access",
            contentType: "application/x-www-form-urlencoded; charset=utf-8",
            datatype: "JSON",
            data: {
                method: method1,
                token: token1,
                p: p1,
                pagesize: pagesize1
            },
            success: function (data) {
                var data1 = JSON.parse(data);
//              console.log(data1);
                if (data1.status === 1) {
                    var html = "";
                    for (var i in data1.data.data) {
                        if (data1.data.data[i].status == 1) {
                            html +=
                                "<div class='am-u-sm-12' style='padding: 10px 20px 15px 20px;background: #fff;margin-bottom: 5px;'><div>";
                            html += "<div class='am-u-sm-9' style='font-size: 16px;padding:0;'>" + data1.data
                                .data[i].code + "</div>";
                            html +=
                                "<div class='am-u-sm-3' style='text-align: right;'><img src='img/Used@2x.png' width='45' /></div></div><div style='clear: both;'></div></div>";
                        } else {
                            var hh = data1.data.data[i].end_time;
                            var date = new Date(hh * 1000);
                            var Y = date.getFullYear() + '-';
                            var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() +
                                1) + '-';
                            var D = (date.getDate() < 10 ? '0' + (date.getDate()) : date.getDate()) + ' ';
                            var h = (date.getHours() < 10 ? '0' + (date.getHours()) : date.getHours()) +
                                ':';
                            var m = (date.getMinutes() < 10 ? '0' + (date.getMinutes()) : date.getMinutes()) +
                                ':';
                            var s = date.getSeconds() < 10 ? '0' + (date.getSeconds()) : date.getSeconds();
                            html +=
                                "<div class='am-u-sm-12' style='padding: 10px 20px 15px 20px;background: #fff;margin-bottom: 5px;'><div>";
                            html += "<div class='am-u-sm-9' style='font-size: 16px;padding:0;'>" + data1.data
                                .data[i].code + "</div>";
                            html +=
                                "<div class='am-u-sm-3' style='text-align: right;'><img src='img/unUse@2x.png' width='45' /></div></div>";
                            html +=
                                "<div class='am-u-sm-12' style='padding:0;font-size:14px;margin-top:3px;'>有效期至：<span>" +
                                Y + M + D + h + m + s +
                                "</span></div><div style='clear: both;'></div></div>";
                        }
                    }
                    if (html == "") {
                        $("#jh_list").html(
                            "<div style='width:60%;margin:20px 20%;clear:both;'><img src='img/roun.png' style='width:100%;'></div>"
                        );
                        $(".tcdPageCode").css("display", "none");
                    } else {
                        $("#jh_list").html(html);
                    }
                    var r = data1.data.total;
                    r = Math.ceil(r / pagesize1);
                    $(".tcdPageCode").createPage({
                        pageCount: r,
                        current: 1,
                        backFn: function (pagesize1) {}
                    });
                } else if (Number(data1.status) == 2) {
                    alert(data1.message);
                    window.location.href = "login.html";
                } else {
                    alert(data1.message);
                }
            }
        });
        $(".tcdPageCode").on("click", 'a', function () {
            var h = $(this).html();
            if (h == "下一页") {
                var t = $('.tcdPageCode  span.current').html();
                t = parseInt(t);
                p1 = t + 1;
            } else if (h == "上一页") {
                var t = $('.tcdPageCode  span.current').html();
                t = parseInt(t);
                p1 = t - 1;
            } else {
                h = parseInt(h);
                p1 = h;
            }
            $.ajax({
                type: 'POST',
                url: "http://www.rice.com/app/api/h5_access",
                contentType: "application/x-www-form-urlencoded; charset=utf-8",
                datatype: "JSON",
                data: {
                    method: method1,
                    token: token1,
                    p: p1,
                    pagesize: pagesize1
                },
                success: function (data) {
                    var data1 = JSON.parse(data);
                    if (data1.status === 1) {
                        var html = "";
                        for (var i in data1.data.data) {
                            if (data1.data.data[i].status == 0) {
                                html +=
                                    "<div class='am-u-sm-12' style='padding: 10px 20px 15px 20px;background: #fff;margin-bottom: 5px;'><div>";
                                html +=
                                    "<div class='am-u-sm-9' style='font-size: 16px;padding:0;'>" +
                                    data1.data.data[i].code + "</div>";
                                html +=
                                    "<div class='am-u-sm-3' style='text-align: right;'><img src='img/Used@2x.png' width='45' /></div></div><div style='clear: both;'></div></div>";
                            } else {
                                var hh = data1.data.data[i].end_time;
                                var date = new Date(hh * 1000);
                                var Y = date.getFullYear() + '-';
                                var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) :
                                    date.getMonth() + 1) + '-';
                                var D = (date.getDate() < 10 ? '0' + (date.getDate()) : date.getDate()) +
                                    ' ';
                                var h = (date.getHours() < 10 ? '0' + (date.getHours()) : date.getHours()) +
                                    ':';
                                var m = (date.getMinutes() < 10 ? '0' + (date.getMinutes()) : date.getMinutes()) +
                                    ':';
                                var s = date.getSeconds() < 10 ? '0' + (date.getSeconds()) : date.getSeconds();
                                html +=
                                    "<div class='am-u-sm-12' style='padding: 10px 20px 15px 20px;background: #fff;margin-bottom: 5px;'><div>";
                                html +=
                                    "<div class='am-u-sm-9' style='font-size: 16px;padding:0;'>" +
                                    data1.data.data[i].code + "</div>";
                                html +=
                                    "<div class='am-u-sm-3' style='text-align: right;'><img src='img/unUse@2x.png' width='45' /></div></div>";
                                html +=
                                    "<div class='am-u-sm-12' style='padding:0;font-size:14px;margin-top:3px;'>有效期至：<span>" +
                                    Y + M + D + h + m + s +
                                    "</span></div><div style='clear: both;'></div></div>";
                            }
                        }
                        $("#jh_list").html(html);
                        var r = data1.data.total;
                        r = Math.ceil(r / pagesize1);
                        $(".tcdPageCode").createPage({
                            pageCount: r,
                            current: p1,
                            backFn: function (pagesize1) {}
                        });
                    } else if (Number(data1.status) == 2) {
                        alert(data1.message);
                        window.location.href = "login.html";
                    } else {
                        alert(data1.message);
                    }
                }
            });
        })
    </script>
</body>

</html>